/*
 * @Descripttion: 
 * @version: 
 * @Author: 高月飞
 * @Date: 2023-11-25 19:31:04
 * @LastEditors: 高月飞
 * @LastEditTime: 2023-11-25 20:59:31
 */
import type { ICustomerData } from "@/types/customer";
import { post, get, put, del } from "@/utils/NetworkRequest/index";
import { objToQueryString } from '@/utils/Tools/ObjectToCharacter';

/**
 * 用户添加
 * @param {object} userData  添加用户表单项数据
 * @returns Promise<number>
 */
export const userSystemEmployeeAddApi = (userData: IEmpoloeeMouler.IUserInfo) => {
    return post<number>('/api/system/employee/add', userData)
}


// 用户列表数据
export const userSystemEmployeeListApi = (page = 1, query = {}, size = 10) => {
    if ('page' in query) {
        delete query.page
    }
    query = objToQueryString(query)
    return get<IEmpoloeeMouler.IUserList>(`/api/system/employee?page=${page}&size=${size}${query}`)

}


//批量删除
export const userSystemEmployeeDeleteApi = (userId: number[]) => {
    return post<number>('/api/system/employee/delete', { userId })
}


// 上传图片
export const uploadSystemEmployeeAvatarApi = (formData: FormData) => {
    console.log(111)
    return post<IEmpoloeeMouler.IUpdateAvatar>('/api/system/employee/uploadAvatar', formData)
}


// 删除上传图片
export const deleteuploadSystemEmployeeAvatarApi = (path: string) => {
    return post<number>('/api/system/employee/deleteuploadAvatar', { path })
}


// 根据用户id返回用户记录
export const getUidSystemEmployeeToInfoApi = (id: number) => {
    return get<IEmpoloeeMouler.IEMOInfo>(`/api/system/employee/${id}`)
}


// 根据用户id修改对应用户记录
export const editUserSystemEmployeeToInfoApi = (id: number, userData: IEmpoloeeMouler.IEMOInfo) => {
    return put<number>(`/api/system/employee/${id}`, userData)
}